﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Collections;
using System.Xml.Linq;

namespace OSVDB_Logic
{
    public class OSVDBStats
    {
        private Dictionary<string, string> stats;

        public OSVDBStats(String url)
        {
            try
            {
                WebClient wc = new WebClient();
                string xml = wc.DownloadString(url);

                XElement ex = XElement.Parse(xml);

                stats = new Dictionary<string, string>();

                stats.Add("vulncount", ex.Element("vulncount").Value);
                stats.Add(ex.Element("vendor0").Value, ex.Element("vendorcount0").Value);
                stats.Add(ex.Element("vendor1").Value, ex.Element("vendorcount1").Value);
                stats.Add(ex.Element("vendor2").Value, ex.Element("vendorcount2").Value);
                stats.Add(ex.Element("vendor3").Value, ex.Element("vendorcount3").Value);
                stats.Add(ex.Element("vendor4").Value, ex.Element("vendorcount4").Value);
                stats.Add(ex.Element("vendor5").Value, ex.Element("vendorcount5").Value);
                stats.Add(ex.Element("vendor6").Value, ex.Element("vendorcount6").Value);
                stats.Add(ex.Element("vendor7").Value, ex.Element("vendorcount7").Value);
                stats.Add(ex.Element("vendor8").Value, ex.Element("vendorcount8").Value);
                stats.Add(ex.Element("vendor9").Value, ex.Element("vendorcount9").Value);
            }
            catch (Exception)
            {
                
            }
        }

        public Dictionary<string, string> Stats
        {
            get
            { 
                return stats;
            }
        }
    }
}
